<link href="__CDN__/assets/css/frontend{$Think.config.app_debug?'':'.min'}.css?v={$Think.config.site.version|htmlentities}" rel="stylesheet">
<link rel="stylesheet" href="/pc/layui/css/layui.css">
<script src="/pc/js/jquery.min.js"></script>
<script src="/pc/layui/layui.js"></script>
<style>
body{padding:0;}	
</style>
<div class="login-main" style="padding:25px 25px 0;">
	<div  id="login-form" class="form-vertical">
		<!--@IndexLoginFormBegin-->
		{:token()}
		<div class="form-group">
			<label class="control-label" for="account">{:__('Account')}</label>
			<div class="controls">
				<input class="form-control" id="account" type="text" name="account" value="" data-rule="required"
					placeholder="{:__('Email/Mobile/Username')}" autocomplete="off">
				<div class="help-block"></div>
			</div>
		</div>
		<div class="form-group">
			<label class="control-label" for="password">{:__('Password')}</label>
			<div class="controls">
				<input class="form-control" id="password" type="password" name="password" data-rule="required;password"
					placeholder="{:__('Password')}" autocomplete="off">
			</div>
		</div>
		<div class="form-group">
			<div class="controls">
				<div class="checkbox inline">
					<label>
						<input type="checkbox" name="keeplogin" checked="checked" value="1"> {:__('Keep login')}
					</label>
				</div>
				<div class="pull-right"><a href="javascript:;" class="btn-forgot">{:__('Forgot password')}</a></div>
			</div>
		</div>
		<div class="form-group">
			<button type="button" onclick="submit()" class="btn btn-primary btn-lg btn-block">{:__('Sign in')}</button>
			<a class="btn btn-default btn-lg btn-block mt-3 no-border" href="javascript:void(0);" onclick="go_register()">{:__("Don't have an account? Sign up")}</a>
		</div>
		<!--@IndexLoginFormEnd-->
		<div>
		    <a class="btn btn-success btn-block mb-2" href="{:addon_url('/wxfollowlogin/index/index')}"><i class="fa fa-wechat"></i> 公众号二维码</a>
		</div>
	</form>
</div>
<script>
	var layer;
	layui.use(function() {
		layer = layui.layer;
	});
	function go_register(){
		parent.window.show_register();
		//layer.closeAll();
	}
	function submit(){
		
		$.ajax({
		    type:"POST",
		    url:"/api.php/login/login",
		    dataType:"json",
		    data:{
		        "account":$('#account').val().trim(),
		        "password":$('#password').val().trim(),
				"keeplogin":$('input[name="keeplogin"]').is(':checked'),
		        "__token__":$('input[name="__token__"]').val().trim(),
		    },
		    success:function(res){
		        console.log(res);
		        if(res.code==0){
		            layer.msg(res.msg,{icon:5});
		            $('input[name="__token__"]').val(res.data.token);
		        }else{
		            layer.msg(res.msg,{icon:6},function(){
		                layer.closeAll();
						parent.window.location.href="{:url('user/index')}";
		            });
		        }
		    }
		});
	} 
</script>